<template>
  <div class="hello">
   <h1>{{num}}---{{mymoney}}---{{myeng}}</h1>
   <button @click="add(3)">点击我触发commit函数</button>
   <button @click="reduceNum(3)">点我触发Action函数</button>
   <button @click="getnew">点击我获取action数据</button>
   <el-row>
  <el-button>默认按钮</el-button>
  <el-button type="primary">主要按钮</el-button>
  <el-button type="success">成功按钮</el-button>
  <el-button type="info">信息按钮</el-button>
  <el-button type="warning">警告按钮</el-button>
  <el-button type="danger">危险按钮</el-button>
</el-row>
  </div>
</template>

<script>
import {mapState,mapMutations,mapActions,mapGetters} from 'vuex'
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  created:function(){
    // console.log(this.$store.state.num)
  },
  methods:{
    ...mapMutations(["addNum"]),
    ...mapActions(["reduceNum",'getnews']),

    add(){
      this.addNum(3)
    },
    reducefn(){
      this.reduceNum(3)
    },
   async getnew(){
    let {data} =await this.$store.dispatch("getnews")
    console.log(data);
    }
    }
  ,computed:{
    ...mapState(["num"]),
    ...mapGetters(["mymoney",'myeng']),
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
